#!../../bin/linux-x86_64/SDS6204

#- You may have to change SDS6204 to something else
#- everywhere it appears in this file

< envPaths

cd "${TOP}"

## Register all support components
dbLoadDatabase "dbd/SDS6204.dbd"
SDS6204_registerRecordDeviceDriver pdbbase

epicsEnvSet "STREAM_PROTOCOL_PATH" "$(TOP)/db"
epicsEnvSet "P" "HALF:BD:"
epicsEnvSet "R" "CT:"
epicsEnvSet("POINTS","2000000")
epicsEnvSet("ETHER","192.168.116.233:5025")

## Ensure that we can transfer a complete waveform
epicsEnvSet(EPICS_CA_MAX_ARRAY_BYTES, 80000000)
cd "${TOP}"

# Set up ASYN ports
drvAsynIPPortConfigure("L0", "$(ETHER)", 0, 0, 0)

## Load record instances
#dbLoadRecords("db/xxx.db","user=ioc")
dbLoadRecords("db/devSDS6204.db","P=$(P),R=$(R),PORT=L0,POINTS=$(POINTS)")

dbLoadRecords("db/devSDS6204-CH.db","P=$(P),R=$(R),PORT=L0,CH=1,POINTS=$(POINTS)")
dbLoadRecords("db/devSDS6204-CH.db","P=$(P),R=$(R),PORT=L0,CH=2,POINTS=$(POINTS)")
#dbLoadRecords("db/devSDS6204-CH.db","P=$(P),R=$(R),PORT=L0,CH=3,POINTS=$(POINTS)")
#dbLoadRecords("db/devSDS6204-CH.db","P=$(P),R=$(R),PORT=L0,CH=4,POINTS=$(POINTS)")

cd "${TOP}/iocBoot/${IOC}"

#set_requestfile_path("./")
#set_savefile_path("./autosave")
#set_pass0_restoreFile("ct_settings.sav")
#set_pass1_restoreFile("ct_settings.sav")
#save_restoreSet_DatedBackupFiles(1)

iocInit

dbpf $(P)$(R)TIM:RANG_SP 2e-5
dbpf $(P)$(R)SetWavWidt WORD
dbpf $(P)$(R)TRIG:SOUR_SP 4
dbpf $(P)$(R)TRIG:SWE_SP NORM
dbpf $(P)$(R)TRIG:LEV_SP 0.4

## Start any sequence programs
#seq sncxxx,"user=ioc"
#var streamDebug 1
# save things every thirty seconds
#create_monitor_set("ct_settings.req", 30,"P=$(P),R=$(R)")
